<template>
  <div class="box">
    <Header />
    <div class="content">
      <h2>我的通知</h2>
      <el-affix>
        <el-tabs class="dot-tab" v-model="activeName" :stretch="true">
          <el-tab-pane label="活动 / 公告" name="tab1">
            <template #label>
              <div class="huodong-box">
                <div>活动 / 公告</div>
                <div class="point-red"></div>
              </div>
            </template>
            <div class="tab-list">
              <div
                class="item"
                v-for="(item, index) in tabList1"
                :key="index"
                @click="handleTab1Click(item)"
              >
                <el-icon :size="24" color="#409eff">
                  <component :is="item.type == 1 ? BellFilled : Notification" />
                </el-icon>
                <div class="text">
                  <h3>{{ item.tit }}</h3>
                  <p class="dateTime">{{ item.date }}</p>
                </div>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="系统通知" name="tab2">
            <div class="tab-list">
              <div
                class="item"
                v-for="(item, index) in tabList2"
                :key="index"
                @click="bookDetails(item)"
              >
                <!-- <el-icon :size="24" color="#409eff">
                  <Flag />
                </el-icon> -->
                <div class="text">
                  <h3>{{ item.tit }}</h3>
                  <p class="dateTime">{{ item.date }}</p>
                </div>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="收到的回复" name="tab3">
            <div class="tab-list tab3-list">
              <div class="item-box" v-for="(item, index) in tabList3" :key="index">
                <div class="item">
                  <el-icon :size="24" color="#409eff">
                    <ChatDotRound />
                  </el-icon>
                  <div class="text">
                    <h3>您的评论有新回复</h3>
                    <p class="dateTime">{{ item.dateTime }}</p>
                    <div class="author">
                      <el-avatar :size="38" />
                      <p>{{ item.name }}：{{ item.text }}</p>
                    </div>
                  </div>
                </div>

                <div class="huiying-box">
                  <div class="dis-row">
                    <img src="@/assets/images/detailas.png" class="tontzhi-tips" alt />
                    <div>查看文章</div>
                  </div>

                  <div class="dis-row huiying-box-right">
                    <img src="@/assets/images/bakc.png" class="tontzhi-tips" alt />
                    <div>回复</div>
                  </div>
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-affix>
    </div>
  </div>
</template>

<script setup>
import Header from "../components/Header.vue";
import {
  Flag,
  BellFilled,
  ChatDotRound,
  Notification
} from "@element-plus/icons-vue";
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const activeName = ref("tab2");

const tabList1 = ref([
  {
    id: "1",
    type: 1,
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  },
  {
    id: "2",
    type: 1,
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  },
  {
    id: "3",
    type: 2,
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  },
  {
    id: "4",
    type: 2,
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  }
]);

const tabList2 = ref([
  {
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  },
  {
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  },
  {
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  },
  {
    type: 2,
    tit:
      "EROLABS工口實驗室玩家專屬！18+輕小说看到飽！Kado+日輕訂閱制免費７日暢讀！",
    date: "2025.08.02 19:00"
  }
]);

const tabList3 = ref([
  {
    dateTime: "2025.08.02 19:00",
    avatarSrc: "",
    name: "周小洮",
    text: "「魯比娜朝這則貼文点了「讚」」"
  }
]);

const bookDetails = item => {
  router.push("/book");
};

const handleTab1Click = item => {
  router.push({ name: "announce_detail", params: { id: item.id } });
};
</script>

<style lang="scss" scoped>
.huiying-box-right {
  margin-left: 1rem;
}
.huiying-box {
  display: inline-flex;
  width: 100%;
  justify-content: flex-end;
  background-color: #f7fafc;
  padding-bottom: 1rem;
  padding-right: 1rem;
  font-size: 0.8rem;
}
.tontzhi-tips {
  width: 1rem;
  margin-right: 0.3rem;
}

.box {
  background: #ffffff;
}

.content {
  max-width: 512px;
  margin: 0 auto;
  padding: 0 20px;

  h2 {
    height: 64px;
    line-height: 64px;
    text-align: center;
  }

  .tab-list {
    display: flex;
    flex-direction: column;
    gap: 16px;

    .item {
      padding: 16px;
      display: flex;
      gap: 16px;
      border-bottom: 1px solid #edf2f7;

      h3 {
        font-weight: 500;
        line-height: 1.5;
        font-size: 14px;
        color: #2d3748;
      }

      .dateTime {
        font-size: 12px;
        font-weight: 400;
        line-height: 1.625;
        color: #718096;
      }
    }
  }

  .tab3-list {
    .item {
      background: #f7fafc;

      .author {
        display: flex;
        align-items: center;
        gap: 16px;
        margin-top: 8px;

        p {
          font-size: 14px;
          font-weight: 400;
          line-height: 2;
          color: #2d3748;
        }
      }
    }
  }
}

.infinite-list {
  height: 400px;
}

.huodong-box {
  display: inline-flex;
}

.point-red {
  width: 0.4rem;
  height: 0.4rem;
  background-color: #fc8775;
  border-radius: 50%;
}
</style>